﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RestFullChatAJAX.Models
{
    public class OauthInfo
    {
        String _oauth_token = String.Empty;

        public String Oauth_token
        {
            get { return _oauth_token; }
            set { _oauth_token = value; }
        }
        String _oauth_token_secret = String.Empty;

        String _redirectURL = String.Empty;

        public String RedirectURL
        {
            get { return _redirectURL; }
            set { _redirectURL = value; }
        }

        public String Oauth_token_secret
        {
            get { return _oauth_token_secret; }
            set { _oauth_token_secret = value; }
        }

        String _oauth_session_handle = String.Empty;

        public String Oauth_session_handle
        {
            get { return _oauth_session_handle; }
            set { _oauth_session_handle = value; }
        }

        String _oauth_expires_in = String.Empty;

        public String Oauth_expires_in
        {
            get { return _oauth_expires_in; }
            set { _oauth_expires_in = value; }
        }

        String _oauth_authorization_expires_in = String.Empty;

        public String Oauth_authorization_expires_in
        {
            get { return _oauth_authorization_expires_in; }
            set { _oauth_authorization_expires_in = value; }
        }

        public OauthInfo(String oauth_token, String oauth_token_secret, String oauth_session_handle)
        {
            Oauth_token = oauth_token.Trim();
            Oauth_token_secret = oauth_token_secret.Trim();
            Oauth_session_handle = oauth_session_handle.Trim();
        }

        public String getHeader(String CONSUMERKEY, String CONSUMERKEYSECRECT)
        {
            String oauth_nonce = DateTime.Now.Millisecond.ToString();
            TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
            double unixTime = ts.TotalSeconds;
            String oauth_timestamp = unixTime.ToString();
            return String.Format("?oauth_consumer_key={0}&oauth_token={1}&oauth_signature_method=PLAINTEXT&oauth_signature={2}{3}&oauth_timestamp={4}&oauth_nonce={5}&oauth_version=1.0&notifyServerToken=1&oauth_verifier=bcd34f",
               CONSUMERKEY, this._oauth_token, CONSUMERKEYSECRECT, this._oauth_token_secret, oauth_timestamp, oauth_nonce);
        }
    }
}